<template>
	<!-- 银行卡绑定 -->
	<view class="bink_bank_main">
		<view class="not_bound_card tc" v-if="!bankList.length">
			<view class="not_bound_card_img">
				<image src="../../../static/image/notBoundCard.png" mode=""></image>
			</view>
			<view class="not_bound_card_tips">
				暂未绑定银行卡，<text @click="handleToAddBankCard">去添加银行卡>></text>
			</view>
		</view>
		<view class="bink_content" v-else>
			<view class="bink_bank_card" v-for="(item, index) in bankList" :key="index">
				<view class="bink_name">
					{{item.opening_bank}}
				</view>
				<view class="card_number">
					<image src="../../../static/image/circle.png"></image>
				</view>
				<view class="card_number_tail">
					<text>{{item.bankLastNumber}}</text>
				</view>
			</view>
			<view class="bink_bank_btns">
				修改
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				binkBankFlag: 0, // 是否绑定银行卡
				bankList: [] // 银行卡列表
				
			}
		},
		onLoad() {
			this.getBankList()
		},
		methods: {
			// 跳转至添加银行卡页面
			handleToAddBankCard () {
				uni.navigateTo({
					url:'../addBankCard/index'
				})
			},
			/** 获取银行卡列表 */
			getBankList() {
				this.$post(this.api.bankList, {}, 'post', { token: uni.getStorageSync('token') }).then((res) => {
					/** 刷新列表 */
					this.bankList = res.data.map((item, i) => ({
						...item,
						bankLastNumber: item.credit_card.substring(item.credit_card.length - 4)
					}))
				}).catch((err) => {
					console.log(err)
				})
			}
		},
	} 
</script>

<style lang="less" scoped>
	@import  "@/asset/less/base.less";
	.bink_bank_main {
		.bink_bank_card {
			height: 300rpx;
			margin-top: 10rpx;
			background: url(../../../static/image/bankcard.png) center no-repeat;
			background-size: 100% 100%;
			.bink_name {
				color: #fff;
				font-size: 30rpx;
				padding: 70rpx 0 52rpx 80rpx;
			}
			.card_number {
				image {
					display: block;
					width: 418rpx;
					height: 17rpx;
					vertical-align: top;
					margin-left: 80rpx;
				}
			}
			.card_number_tail {
				line-height: 0;
				font-size: 60rpx;
				color: #fff;
				padding: 13rpx 76rpx 0 0;
				text {
					float: right;
				}
			}
		}
		.bink_bank_btns {
			margin: 253rpx 60rpx 0;
			color: #fff;
			text-align: center;
			height: 98rpx;
			font-size: 36rpx;
			line-height: 98rpx;
			border-radius: 20rpx;
			background: linear-gradient(90deg, #CFA461 0%, #DCBB7E 100%);
		}
	}
	.not_bound_card {
		.not_bound_card_img {
			padding: 337rpx 0 48rpx 0;
			image {
				width: 310rpx;
				height: 242rpx;
			}
		}
		.not_bound_card_tips {
			font-size: 26rpx;
			color: #666;
			text {
				color: #D7B374;
			}
		}
	}
</style>
